#!/usr/bin/perl -w # for syntax highlighting
# CSS-V1

# Take all the args and update existing section details
# given section and sec_* reader_* and publisher_* values...
# redirect to page in the LP parameter.
use gri_secmgr qw(get_cookie_value redirect_header);
use gri_user_alert_config;
use gri_database;

sub mm_form_docrepos_modify_group_process {
	my $str="";

	my $db_dir=$::GRI_FRONTEND->get_global_directory("database");
	my $DB=new gri_database("$db_dir/gri.db");
	
	my $group=$::PARAM{group};
	my $group_description=$::PARAM{group_description};

	my @R=();
	for my $ckey (keys %::PARAM) {
		if($ckey =~ /^user_(.*)/) {
			push @R,$1;
		}
	}
	my $group_users=join(",",@R);
	$group_users="" if !defined($group_users);

	# We have all the information so update the group details
	my ($rc,$msg)=$DB->modify_group(group=>$group,
		description=>$group_description,
		users=>$group_users);

	if($rc!=1) {
		my $serror="Error Updating Existing Group";
		my $error=$msg;
		my $link=link_to_str("","","show_generic_error","?serror=".string_to_hex($serror).",error=".string_to_hex($error));
		if(!exists($::PARAM{lp})) {
			# We need to encode the current data for repopulation into the form!
			my $s="";
			$s.="group=".string_to_hex($group);
			$s.="::group_description=".string_to_hex($group_users);
			$s.="::group_users=".string_to_hex($group_users);
			$link.=",previouspage=form_docrepos_group_modify_do::$s";
		}
		redirect_header(path => $link);
		exit;
	}

	my $link=link_to_str("","","/admin_page","");
	redirect_header(path => $link);
	exit;
}

# vim: ts=4:sw=4
